<?php
namespace app\admin\controller;

class Order extends Common
{
    public function order_list()
    {
        $ret = db('order')->alias("a")->join("user u","a.user_id=u.user_id")
        ->field('a.*,u.user_tell')
        ->order("statu")->paginate(6);
        $pageHtml = $ret->render();
        $this->assign('ret',$ret);
        $this->assign('pageHtml',$pageHtml);
        $this->assign('pick',5);
        return view('order_list');
    }

    public function sendFood()
    {
        $order_id = $_GET['id'];
        $ret = db('order')->where("id = {$order_id}")->update(array('statu'=>2));
        if($ret){
            return [
                'msg' => '成功发货',
                'status' => 1
            ];
        }else{
            return [
                'msg' => '发货失败',
                'status' => 0
            ];
        }
    }

    public function acceptOrder()
    {
        $order_id = $_GET['id'];
        $ret = db('order')->where("id = {$order_id}")->update(array('statu'=>1));
        if($ret){
            return [
                'msg' => '接受订单',
                'status' => 1
            ];
        }else{
            return [
                'msg' => '接受订单失败',
                'status' => 0
            ];
        }
    }
}
